<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <title>Title</title>
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <script type="text/javascript" src="/skin/js/jquery.min.js"></script>
   <link rel="stylesheet" type="text/css" href="/skin/css/style.css">
</head>
<body>
<div class="header">
    <div class="main">
       <!--  <a href="/index.php"><span class="left"></span></a> -->
       <span class="left" id="lefts"></span>
       <div class="mainbox">
       <div class="plays">
        <span class="play">玩法</span>
          <!-- <div class="select-play"><span>选择玩法<i class="bett-attr"></i></span></div> -->
          <div class="select-play"><span><span class="gp1">选择玩法</span>-<span class="gp2"></span><i class="bett-attr"></i></span></div>
       </div>
       </div>
       <div class="box" style="display: none">
          <div class="playgroup">
        <?php
         $sql="select id, groupName, enable from {$this->prename}played_group where enable=1 and type=? order by sort";
         $groups=$this->getObject($sql, 'id', 15);
         $groupid = array();
         if($groups){
            foreach ($groups as $key => $group) {
            $groupid[] = $group['id'];
            if(!$this->groupId) $this->groupId=$group['id'];
              ?>
                <div id="group<?=$group['id']?>" onclick="group(<?=$group['id']?>)"><?=$group['groupName']?></div>
              <?php
            }
         }
         ?>
          </div>
          <div class="clear"></div>
<?php
    $sql="select groupName from {$this->prename}played_group where id=?";
    //$groupName=$this->getValue($sql, $this->groupId);
    $groupName=$this->getValue($sql, $groupid[1]);
    $sql="select id, name, playedTpl, enable  from {$this->prename}played where enable=1 and groupId=? order by sort";
    //$playeds=$this->getRows($sql, $this->groupId);
    $playeds=$this->getRows($sql, $groupid[1]);
    if($playeds){
      foreach ($playeds as $key => $groups) {
         ?>
            <div><?= $groups['name']?></div>
         <?php
      }
    }

  ?>
       </div>
</div>
  <?php
          date_default_timezone_set('PRC');
          $timeinfo = time();
          $datassc = $this->getRows("select * from {$this->prename}datassc order by id desc limit 2");
          $msg = array();
          if($datassc){
            foreach ($datassc as $key => $value) {
               $msg[$key]['qishu'] = $value['qishu'];
               $msg[$key]['time'] = $value['time'];
            }
            $feng = strtotime($msg[0]['time'])-120;
            $fengtime = date("Y/m/d H:i:s",$feng);

          }else{
              $msg[1]['qishu'] = "";
              $msg[0]['qishu'] = 1;
          }
  ?>
<div class="mains">
  <div class="mains-left">
    <div class="fentext"><span><?php echo $msg[1]['qishu'];?></span>期</div>
    <div> fhgh</div>
  </div>
  <div class="mains-right">
    
    <div class="fentext">距<span id="qishu"><?php echo $msg[0]['qishu'];?></span>期截止</div>
    <div> 

   </div>
    <span style="display:none"><span id="fp_m">00分</span><span id="fp_s">00秒</span></span>  
    <!--   开奖 <span style="border:1px solid #b18b8b;padding:0 4px;" ><span id="kj_m">00分</span><span id="kj_s">00秒</span></span> -->
      <div class="kai">
        <span id="timeh1">0</span>
        <span id="timeh2">0</span>
        <span class="time-kong"></span>
<!--         <span id="times">:</span> -->
        <span id="time1">0</span>
        <span id="time2">0</span>
        <!-- <span id="times">:</span> -->
        <span class="time-kong"></span>
        <span id="time3">0</span>
        <span id="time4">0</span>
      </div> 
</div>
  </div>
</div>
<div class="footer">footer</div>
</body>
</html>
<script type="text/javascript">
$('#lefts').click(function(){
  window.history.go(-1);
})  
$('.plays').click(function(){
  if($('.box').css('display')=='none'){
    $('.box').show();
  }else{
    $('.box').hide();
  }
  
});
function group(id){
  var msg=$("#group"+id).text(); 
  $(".gp1").html(msg);
 /* $(".box").css({ "display" : 'none' });*/
}
//var time = "1524446301";
var time = <?php echo json_encode($timeinfo);?>;
var NowTime = new Date();
var test = NowTime.getTime();
test = Math.floor(test/1000);
var cha = time-test;

//开奖倒计时
function GetRTime1(){

 // var fp_time = "2018-04-23 09:22:50";
    var fp_time = <?php echo json_encode($msg[0]['time']);?>;
    var EndTime= new Date(fp_time);
    var NowTime = new Date();

    var t =EndTime.getTime() - (NowTime.getTime()+cha*1000);
    var m=0;
    var s=0;
    var h=0;
    if(t>=0){
      h=Math.floor(t/1000/3600);
      m=Math.floor(t/1000/60%60);
      s=Math.floor(t/1000%60);
    }
  if(h<=0){
      if(m<10){
          $("#time1").html(0);
          $("#time2").html(m.toString().split(""));
      }else{
          $("#time1").html(m.toString().split("")[0]);
          $("#time2").html(m.toString().split("")[1]);
      }
      if(s<10){
          $("#time3").html(0);
          $("#time4").html(s.toString().split(""));
      }else{
          $("#time3").html(s.toString().split("")[0]);
          $("#time4").html(s.toString().split("")[1]);
      }
    if(m==0 && s==0 && h==0){ 
      clearInterval(window.kaijiang);
      var qishu = $("#qishu").text();
      $.post('/index.php/index/sscplay',{qishu:qishu},function(data){
          if(data == 200){ 
            window.location.href="/index.php/index/ssc";
          }
      });
           window.location.href="/index.php/index/ssc";
    }
  }else{
    
    $(".kaijiang").html('尚未开启');
    
    
  }
    
}
var kaijiang = setInterval(GetRTime1,0);
//封盘倒计时
function GetRTime(){

    var NowTime = new Date();

    var fp_time =   <?php echo json_encode($fengtime);?>;
    var EndTime= new Date(fp_time);
    
    var t =EndTime.getTime() - (NowTime.getTime()+cha*1000);
  
    //console.log(EndTime.getTime() NowTime.getTime());
    var m=0;
    var s=0;
    var h=0;
    if(t>=0){
      h=Math.floor(t/1000/3600);
      m=Math.floor(t/1000/60%60);
      s=Math.floor(t/1000%60);
    }
  //console.log(h);
  if(h<=0){
    document.getElementById("fp_m").innerHTML = m + "分"
    document.getElementById("fp_s").innerHTML = s + "秒";
    if(m==0 && s==0 && h==0){
       clearInterval(window.fengpan);
       $.post('/index.php/index/kaijiang',function(data){
        /* alert(data);*/
      });
    }
  }else{
    $(".fengpan").html('尚未开启');
    
  }
    
}
var fengpan = setInterval(GetRTime,0);

</script>
